<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
           text-align: center;
        }
        .login{
            width: 400px;
            height: 300px;
            position: fixed;
            border: #ebebeb solid 1px;
            left: 50%;
            top: 50%;
            background-color: #fff;
            box-shadow: 0px 0px 20px #ddd;
            z-index: 999;
            transform: translate(-50%,-50%);
            display: none;
        }
        .login-title{
            width: 100%;
            margin: 10px 0px 0px 0px ;
            text-align: center;
            line-height: 40px;
            height: 40px;
            font-size: 18px;
            position: relative;
            cursor: pointer;
        }
        .login-input-content{
            margin-top: 20px;
        }
        .login-input label{
            float: left ;
            width: 90px;
            padding-right: 10px;
            text-align: right;
            line-height: 35px;
            height: 35px;
            font-size: 14px;
        }
        .login-bg{
            display: none;
            width: 100%;
            height: 100%;
            position: fixed;
            top: 0;
            left: 0px;
            background-color: rgba(0, 0, 0, 0.3);
        }
        a{
            text-decoration: none;
            color: #000;
        }
        .login-button a{
            display: block;
        }
        .login-input input.list-inputP{
            float: left;
        }
        .head{
            text-align: center;
            margin-top: 20px;
        }
        .login-input{
            overflow: hidden;
            margin: 0px 0px 20px 0px ;
        }
        .login-tit span{
            position: relative;
            font-size: 12px;
            right: -20px;
            top: -30px;
            background: #fff;
            border: #ebebeb solid 1px;
            width: 40px;
            height: 40px;
            border-radius: 20px;
        }
    </style>
</head>
<body>
    <div class="login-header"><a id="link" href="javascript:'">点击我</a></div>
    <div id="login" class="login">
        <div id="title" class="login-title">登录会员
            <span><a id="closeBtn" href="javascript:void(0)" class="close-login">关闭</a></span>
        </div>
        <div class="login-input-content">
            <div class="login-input">
                <label>用户名：</label>
                <input placeholder="请输入用户名">
            </div>
            <div class="login-input">
                <label>登陆密码：</label>
                <input placeholder="请输入密码">
            </div>
        </div>
        <button>登录</button>
        <div id="bg" class="login-bg"></div>
    </div>
    <script>
        let title = document.querySelector('.title');
        let mask = document.querySelector('.login-bg ');
        let link = document.querySelector('#link');
        let login = document.querySelector('.login');
        let closeBtn = document.querySelector('#closeBtn');
        //点击弹出框显示这个login和mash
         link.addEventListener('click',function(){
           mask.style.display = 'block';
           login.style.display = 'block';
        })
        //点击closeBtn隐藏
        console.log(closeBtn);
        closeBtn.addEventListener('click',function(){
           mask.style.display = 'none';
           login.style.display = 'none';
        })
    </script>
</body>
</html>